/***********************************************************************************
    Filename: hal_board.c

    Copyright 2007 Texas Instruments, Inc.
***********************************************************************************/

#include "hal_types.h"
#include "hal_digio.h"
#include "hal_int.h"
#include "hal_mcu.h"
#include "hal_board.h"
#include "hal_spi.h"
#include "hal_uart.h"
#include "hal_defs.h"


//------------------------------------------------------------------------------
//  Global variables
//------------------------------------------------------------------------------
const digioConfig pinLed1   = {1, 0, HAL_DIGIO_OUTPUT, 0, BIT0};
const digioConfig pinLed2   = {1, 1, HAL_DIGIO_OUTPUT, 0, BIT1};
const digioConfig pinBtn    = {1, 2, HAL_DIGIO_INPUT,  0, BIT2};
const digioConfig pinGDO0   = {2, 6, HAL_DIGIO_INPUT,  0, BIT6};
const digioConfig pinGDO2   = {2, 7, HAL_DIGIO_INPUT,  0, BIT7};


//------------------------------------------------------------------------------
//  void halBoardInit(void)
//
//  DESCRIPTION:
//    Set up board. Initialize MCU and configure I/O pins.
//------------------------------------------------------------------------------
void halBoardInit(void)
{
	// Turn off watchdog and set up system clock. Set system clock to 1 MHz using
	// internal DCO
	halMcuInit();

	// Init SPI
    halSpiInit(0);

    // Init UART
    halUartInit(0,0);

    // Init IO
    halDigioConfig(&pinLed1);
    halDigioConfig(&pinLed2);
    halDigioConfig(&pinGDO0);
    halDigioConfig(&pinGDO2);
    halDigioConfig(&pinBtn);

    // Need to enable pull up on the button input
    P1REN |= BIT2;
    P1OUT |= BIT2;

    // Enable global interrupts
    halIntOn();
}
